package com.zrwl.poscloud.xo.mapper;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zrwl.poscloud.base.entity.Company;
import com.zrwl.poscloud.base.superI.SuperMapper;
import com.zrwl.poscloud.xo.vo.CompanyVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author xuzhixiang
 * @since 2018-09-04
 */
public interface CompanyMapper extends SuperMapper<Company> {
    /**
     * 获取当前商户的uid
     *
     * @param superCompanyCode 商户code
     * @return
     */
    String selectCompany(String superCompanyCode);

    CompanyVO getCurrentCompanyInformation(String uid);

    @Select("<script>" +
            "  SELECT uid,company_code companyCode,short_name companyName,full_name fullName,member_config FROM t_company WHERE status=1 " +
            "   <if test='param.keyword!=null and param.keyword!=&quot;&quot;'>" +
            "    and short_name LIKE CONCAT('%',#{param.keyword},'%')" +
            "    or full_name LIKE CONCAT('%',#{param.keyword},'%')" +
            "   </if>" +
            "  ORDER BY short_name ASC" +
            "</script>"
    )
    public IPage<CompanyVO> getPageListSimple(Page page, @Param("param") CompanyVO companyVO);

    public IPage<CompanyVO> getCurrentCompany(Page page, @Param("param") CompanyVO companyVO);

    public CompanyVO getCompanyByEmployeeUid(String companyCode);

    @Select("<script>" +
            "  SELECT * FROM t_company WHERE status=1 AND uid=#{companyUid} " +
            "</script>"
    )
//    public CompanyConfigVO getCompanyConfigByUid(@Param("companyUid") String companyUid);
    public String superCompanyCode(@Param("name")String name);

    List<Company> getCompanyMesByCodeAndName(@Param("param")CompanyVO companyVO);
}
